package com.yw.android.common.utils;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;


public class SignUtil {
    /**
     * 获取防篡改Key
     *
     * @param signs
     * @param appKey
     * @return
     * @throws Exception
     */
    public static String getSignature(Map<String, String> signs, String appKey) throws Exception {
        StringBuilder builder = new StringBuilder();
        TreeMap<String, String> t = new TreeMap<String, String>(signs);
        Set<Map.Entry<String, String>> entries = t.entrySet();
        // 按照TreeMap默认便利算法序列化签名参数
        for (Map.Entry<String, String> entry : entries) {
            builder.append(entry.getKey()).append("=").append(entry.getValue());
        }
        builder.append(appKey);
        return MD5.getString(builder.toString());
    }
}
